/*四舍五入*/
var rounding=function (count,times,bit) {
    return parseFloat(Number(count*times).toFixed(bit));
}
/*四舍五入 --end*/

var color = ['#fff'];
var BJData = [
];
var maxX_bd=[],maxY_bd=[],minX_bd=[],minY_bd=[],cellcolor=[],hour_all_detail=[],work_hour_all_detail=[];
var series = [];
var option={};
var myChart;
var marketPage=null,mediapage=null,audiences=null;
var pStart=null,pEnd=null,rectangle=null;
var fromCoordAll=[], toCoordAll=[];
// 迁移接口
var transferInf=function (data) {
    console.log(data);
    for(var k in data.rows){
        for(var i in data.rows[k].relate_grid_list){
            fromCoordAll.push([data.rows[k].relate_grid_list[i].center_bd_lng,data.rows[k].relate_grid_list[i].center_bd_lat]);
            toCoordAll.push([data.rows[k].center_bd_lng,data.rows[k].center_bd_lat]);
        }
    }
}
var convertData = function(data) {
    var res = [];
    for (var i = 0; i <fromCoordAll.length; i++) {
      var dataItem = data[i];
      var fromCoord=fromCoordAll[i];
      var toCoord=toCoordAll[i];
      // var fromCoord = geoCoordMap[dataItem[0].name];
      // var toCoord = geoCoordMap[dataItem[1].name];
      if (fromCoord && toCoord) {
         res.push({
            // fromName: dataItem[0].name,
            // toName: dataItem[1].name,
            coords: [fromCoord, toCoord]
        });
     }
 }
 return res;
};
var bmap;
var bmaps
var detailsInf=function (data) {
    getData('post',url,transfer,SinglePARM,transferInf,$('body'));
    console.log(data);
    marketPage= data.rows.MarketPage;
    mediapage = data.rows.MediaPage;
    audiences = data.rows.Audience;

// 迁徙
myChart = echarts.init(document.getElementById('map'));
var startPoint=null;
if (sessionStorage.getItem('fnid')) {
   startPoint= {
    x:mediapage.grid_list[0].center_bd_lng,
    y:mediapage.grid_list[0].center_bd_lat
}
$('.back').append('<i class="planBackIcon"></i><span class="planBack">方案详情</span>');
$('.media_title').html('栅格'+mediapage.grid_list[0].fnidName);
}else if(sessionStorage.getItem('coordIng')&&sessionStorage.getItem('coordLat')){
    console.log('yesy');
    startPoint={
        x:sessionStorage.getItem('coordIng'),
        y:sessionStorage.getItem('coordLat')
    }
}else{
    startPoint = {
        x: 116.406281,
        y: 39.916485
    };
    $('.back .planBack').remove();
    $('.back .planBackIcon').remove();
}
// 地图样式
bmap = {
    center: [startPoint.x, startPoint.y],
    zoom: 12,
    roam: 'move',
    mapStyle:{styleJson:[
      {
        "featureType": "background",
        "elementType": "all",
        "stylers": {
          "color": "#2d3039"
      }
  },
  {
    "featureType": "poi",
    "elementType": "labels.icon",
    "stylers": {
      "color": "#3d85c6"
  }
},
{
    "featureType": "highway",
    "elementType": "all",
    "stylers": {
      "visibility": "off"
  }
},
{
    "featureType": "local",
    "elementType": "all",
    "stylers": {
      "lightness": -76,
      "saturation": -77
  }
},
{
    "featureType": "arterial",
    "elementType": "all",
    "stylers": {
      "color": "#d0e0e3",
      "lightness": -73,
      "saturation": -77
  }
}
]}
}
if (sessionStorage.getItem('fnid')) {
    bmap.zoom=15;
}else if (sessionStorage.getItem('zoom')) {
    bmap.zoom=sessionStorage.getItem('zoom');
}
option = {
   bmap: bmap,
   color: ['gold', 'aqua', 'lime'],
   backgroundColor: '#404a59',

   tooltip: {
      trigger: 'item'
  },
  geo: {
      map: 'bmap',
      polyline: true,
      progressiveThreshold: 500,
      progressive: 200,
      label: {
         emphasis: {
            show: false
        }
    },
    roam: true,
    itemStyle: {
     normal: {
        areaColor: '#323c48',
        borderColor: '#404a59'
    },
    emphasis: {
        areaColor: '#2a333d'
    }
}
},
series: series,
};
myChart.setOption(option);
 bmaps = myChart.getModel().getComponent('bmap').getBMap();
$('.databtn_wrp a').on('click',function () {
  sessionStorage.setItem('coordIng',bmaps.getCenter().lng);
  sessionStorage.setItem('coordLat',bmaps.getCenter().lat);
  sessionStorage.setItem('zoom',bmap.zoom);
  // console.log(sessionStorage.getItem('coordIng'),sessionStorage.getItem('coordLat'));
})
var allcellOverlay = bmaps.getOverlays();
// 每次重新加载，清除覆盖物
for (var i = 0; i < allcellOverlay.length; i++) {
    if(allcellOverlay[i].Qa==true){
        bmaps.removeOverlay(allcellOverlay[i]);
    }
}
bmaps.setMinZoom(12);
// 添加覆盖物
var rectangleAll=[],cellcolorAll=[];
maxX_bd=[],maxY_bd=[],minX_bd=[],minY_bd=[],cellcolor=[],hour_all_detail=[],work_hour_all_detail=[];
for(var k in mediapage.grid_list){
    maxX_bd.push(mediapage.grid_list[k].maxX_bd);
    maxY_bd.push(mediapage.grid_list[k].maxY_bd);
    minX_bd.push(mediapage.grid_list[k].minX_bd);
    minY_bd.push(mediapage.grid_list[k].minY_bd);
    cellcolorAll.push(mediapage.grid_list[k].defaultRGB);
    cellcolor=mediapage.grid_list[k].defaultRGB;
    hour_all_detail.push(mediapage.grid_list[k].hour_all_detail);
    work_hour_all_detail.push(mediapage.grid_list[k].work_hour_all_detail);
    pStart = new BMap.Point(maxX_bd[k],maxY_bd[k]);
    pEnd = new BMap.Point(minX_bd[k],minY_bd[k]);
    rectangle = new BMap.Polygon([
        new BMap.Point(pStart.lng,pStart.lat),
        new BMap.Point(pEnd.lng,pStart.lat),
        new BMap.Point(pEnd.lng,pEnd.lat),
        new BMap.Point(pStart.lng,pEnd.lat)
        ], {strokeWeight:0.000001, strokeOpacity:0.00000001,fillColor:cellcolor});
    rectangleAll.push(rectangle);
    rectangleAll[k].find=mediapage.grid_list[k].find;
    rectangleAll[k].addEventListener('click', function() {
        if (!sessionStorage.getItem('fnid')) {
            sessionStorage.setItem('fnid',this.find);
            var SinglePARM={
                orderResultId:sessionStorage.getItem('orderResultId'),
                fnid:this.find,
                orderId:sessionStorage.getItem('orderId'),
                cityCode:sessionStorage.getItem('cityCode')   
            }
            getData('post',url,SingleCell,SinglePARM,detailsInf,$('body'));
        }
    });
    bmaps.addOverlay(rectangle); 
}
// 时间轴点击事件
$('.axiscell').on('click',function () {
    var colorindex=$(this).index();
    for (var i = 0; i < rectangleAll.length; i++) {
        bmaps.removeOverlay(rectangleAll[i]);
    }
    rectangleAll=[];
    if ($('.axis').hasClass('workday')) {
        console.log(work_hour_all_detail);
        for(var k in mediapage.grid_list){
            cellcolorAll.push(work_hour_all_detail[k][colorindex]);
            cellcolor=work_hour_all_detail[k][colorindex];
            pStart = new BMap.Point(maxX_bd[k],maxY_bd[k]);
            pEnd = new BMap.Point(minX_bd[k],minY_bd[k]);
            rectangle = new BMap.Polygon([
                new BMap.Point(pStart.lng,pStart.lat),
                new BMap.Point(pEnd.lng,pStart.lat),
                new BMap.Point(pEnd.lng,pEnd.lat),
                new BMap.Point(pStart.lng,pEnd.lat)
                ], {strokeWeight:0.000001, strokeOpacity:0.00000001,
                    fillColor:cellcolor});
            rectangleAll.push(rectangle);
            bmaps.addOverlay(rectangle);
        }
    }else{
        for(var k in mediapage.grid_list){
           cellcolor=hour_all_detail[k][colorindex];
           pStart = new BMap.Point(maxX_bd[k],maxY_bd[k]);
           pEnd = new BMap.Point(minX_bd[k],minY_bd[k]);
           cellcolorAll.push(hour_all_detail[k][colorindex]);
           rectangle = new BMap.Polygon([
            new BMap.Point(pStart.lng,pStart.lat),
            new BMap.Point(pEnd.lng,pStart.lat),
            new BMap.Point(pEnd.lng,pEnd.lat),
            new BMap.Point(pStart.lng,pEnd.lat)
            ], {strokeWeight:0.000001, strokeOpacity:0.00000001,
                fillColor:cellcolor});
           rectangleAll.push(rectangle);
           bmaps.addOverlay(rectangle);
       }
   }
})
//  接口数据
$('.media_data #c_People').html(mediapage.handlePlan.va.countPeople);
$('.media_data #mediaNumber').html(mediapage.handlePlan.va.mediaNumber);
$('.data_item .vaCNum').html(rounding(mediapage.handlePlan.va.vaC,1,1));
$('.data_item .vaRNum').html(rounding(mediapage.handlePlan.va.vaR,1,1));
$('.data_item .vaFNum').html(rounding(mediapage.handlePlan.va.vaF,1,1));
$('.data_item .GRPNum').html(rounding(mediapage.handlePlan.va.vaGRP,1,1));
$('.data_item .CMPNum').html(rounding(mediapage.handlePlan.va.vaCPM,1,1));
$('.locatinfo #location').html(mediapage.cityName);
$('.locatinfo #Describe').html(mediapage.weather.cityDescribe);
$('.locatinfo #Season').html(mediapage.weather.citySeason);
$('.locatinfo #nowDate').html(mediapage.weather.nowDate);
$('.weather .temperature').html(mediapage.weather.temperature);
$('.weather .cond').html(mediapage.weather.cond);
$('.weather .wind').html(mediapage.weather.wind);
$('.weather .qlty').html(mediapage.weather.qlty);
$('.weather .pm25').html(mediapage.weather.pm25);
var audiAgetype=[],audiAgenum=[];
for (var k in audiences.Age) {
    audiAgetype.push(audiences.Age[k].type);
    audiAgenum.push(audiences.Age[k].number);
}
var Audience= audiences.Audience.split(',');
var Preference=audiences.Preference.split(',');
var audistr='';
var Preferencestr='';
var colorList=['#afb1be','#da6423','#155aee','#fc3030','#febd01','#33c15d','#afb1be','#da6423','#155aee','#fc3030','#febd01','#33c15d','#afb1be','#da6423','#155aee','#fc3030','#febd01','#33c15d',];
for (var k in Audience) {
    audistr+='<div><div class="entry-trangle" style="border-right-color:'+colorList[k]+'"><i class="circle"></i></div><span class="auditag" style="background:'+colorList[k]+'">'+Audience[k]+'</span></div>'
}
for (var k in Preference) {
    Preferencestr+='<div><div class="entry-trangle" style="border-right-color:'+colorList[k]+'"><i class="circle"></i></div><span class="auditag" style="background:'+colorList[k]+'">'+Preference[k]+'</span></div>'
}
$('.AudienceTag').append(audistr);
$('.PreferenceTag').append(Preferencestr);

/**
 * 图表
 * 受众年龄分布myChartaudiAge，受众性别比例myChartaudiSex
 */


 var myChartaudiAge = echarts.init(document.getElementById('audiAge'));
 var optionaudiAge = {
    tooltip: {},
    title:{
        text:'TGA覆盖人数统计的年龄分布情况（单位/岁）',
        textStyle:{
            color:'#269ee4',
            fontSize:12
        }
    },
    grid:{
        x:0,
        y2:80,
    },
    xAxis: {
        data:  audiAgetype,
        axisTick:{
            show:false
        },
        axisLabel:{
           interval : 0,
           formatter:function(audiAgetype)  
           {  
            var hy='';
            if (audiAgetype.length>3) {
                hy= audiAgetype.substring(0,3)+"……";
            }else{

                hy=audiAgetype;
            }
            return hy.split("").join("\n");
        },
        textStyle: {
            color: '#fff',
            fontStyle: 'normal',
            fontFamily: '微软雅黑',
            fontSize: 10,
        }

    },
},
yAxis: {
    show:false,
},
series: [{              
    type: 'bar',
    data: audiAgenum,
    barWidth: '15',
    itemStyle:{
        normal:{
            barBorderRadius:[10,10,0,0],
            color:'#fff'
        },

    },
    label:{
        normal:{
            show: true,
            position: 'top'
        }
    }
}]
};
myChartaudiAge.setOption(optionaudiAge);
var myChartaudiSex = echarts.init(document.getElementById('audiSex'));
var mandata=rounding(audiences.Sex[1].ratio,1,1);
var womandata=rounding(audiences.Sex[0].ratio,1,1);
var pathSymbols = {
    sexman:'image://',
    sexwoman:'image://'
};
var labelSetting = {
    normal: {
        show: true,
        position: 'right',
        offset: [10, 0],
        textStyle:{
            fontSize: 16,
            color:'#fff'
        },
        formatter:'{c}%'
    }
};
var audiSex = {
    tooltip: {
        trigger: 'axis',
        axisPointer: {
            type: 'shadow'
        },
        formatter:'{c}%'
    },
    grid: {
        containLabel: true,
        left: 0,
        right:90,

    },
    yAxis: {
        show:false,
        data: [ '', ''],
        inverse: true,
        axisLine: {show: false},
        axisTick: {show: false},
        axisLabel: {
            margin: 4,
            textStyle: {
                fontSize: 14
            }
        },
    },
    xAxis: {
        splitLine: {show: false},
        axisLabel: {show: false},
        axisTick: {show: false},
        axisLine: {show: false}
    },
    series: [{
        type: 'pictorialBar',
        label: labelSetting,
        symbolClip: true,
        symbolRepeat: true,
        symbolSize: ['23', '37'],
        symbolMargin:'10',
        barCategoryGap: '40%',
        data: [{
            value: mandata,
            symbol: pathSymbols.sexman
        },{
            value: womandata,
            symbol: pathSymbols.sexwoman
        }
        ]
    }]
};
myChartaudiSex.setOption(audiSex);
var myChartfamily = echarts.init(document.getElementById('audifamily'));
var Familytype = [];
var familyratio = [];
for(var k in audiences.Jiating){
    Familytype.push(audiences.Jiating[k].type);
    familyratio.push(audiences.Jiating[k].ratio);
}
var family = {
    textStyle:{
        color:['#fff'],
    },
    tooltip: {
        trigger: 'item',
        formatter: function(params, ticket, callback) {
            var res = params.seriesName;
            res += '<br/>' + params.name + ' : ' + params.percent + '%';
            return res;
        }
    },
    grid: {
        left:0,
        bottom: 80
    },
    xAxis: [{
        type: 'category',
        axisLine: {
            show: false
        },
        axisTick: {
            show: false
        },
        axisLabel: {
            interval: 0
        },
        data: Familytype
    }],
    yAxis: [{
        show: false
    }],
    series: [
    {
        center: ['15%', '50%'],
        radius:['20%','30%'],
        name: Familytype[0],
        type: 'pie',
        labelLine: {
            normal: {
                show: false
            }
        },
        data: [{
            value: familyratio[0],
            name: '百分比',
            label: {
                normal: {
                    formatter: '{d} %',
                    position: 'center',
                    show: true,
                    textStyle: {
                        fontSize: '16',
                        fontWeight: 'bold',
                        color: '#fff'
                    }
                }
            },
            itemStyle: {
                normal: {
                    color: '#e97603'
                }
            }
        }, {
            value: 100-familyratio[0],
            name: '',
            tooltip: {
                show: false
            },
            itemStyle: {
                normal: {
                    color: '#393d49'
                },
                emphasis: {
                    color: '#393d49'
                }
            },
            hoverAnimation: false
        }]
    }, {
        center: ['45%', '50%'],
        radius: ['20%','30%'],
        name: Familytype[1],
        type: 'pie',
        labelLine: {
            normal: {
                show: false
            }
        },
        data: [{
            value: familyratio[1],
            name: '百分比',
            label: {
                normal: {
                    formatter: '{d} %',
                    position: 'center',
                    show: true,
                    textStyle: {
                        fontSize: '16',
                        fontWeight: 'bold',
                        color: '#fff'
                    }
                }
            },
            itemStyle: {
                normal: {
                    color: '#0376e9'
                }
            }
        }, {
            value: 100-familyratio[1],
            name: '',
            tooltip: {
                show: false
            },
            itemStyle: {
                normal: {
                    color: '#393d49'
                },
                emphasis: {
                    color: '#393d49'
                }
            },
            hoverAnimation: false
        }]
    }, {
        name: Familytype[2],
        center: ['75%', '50%'],
        radius: ['20%','30%'],
        type: 'pie',
        labelLine: {
            normal: {
                show: false
            }
        },
        data: [{
            value: familyratio[2],
            name: '百分比',
            label: {
                normal: {
                    formatter: '{d} %',
                    position: 'center',
                    show: true,
                    textStyle: {
                        fontSize: '16',
                        fontWeight: 'bold',
                        color: '#fff'
                    }
                }
            },
            itemStyle: {
                normal: {
                    color: '#e90376'
                }
            }
        }, {
            value: 100-familyratio[2],
            name: '',
            tooltip: {
                show: false
            },
            itemStyle: {
                normal: {
                    color: '#393d49'
                },
                emphasis: {
                    color: '#393d49'
                }
            },
            hoverAnimation: false
        }]
    }]
};
myChartfamily.setOption(family);

var myChartPoptype = echarts.init(document.getElementById('audiPoptype'));
var dataAxis = [],data = [];
for(var k in audiences.RenkouLeixing){
    dataAxis.push(audiences.RenkouLeixing[k].type);
    data.push(audiences.RenkouLeixing[k].number);
}
var Poptype = {
    textStyle:{
        color:['#fff'],
    },
    title:{
        text:'TGA人口类型（单位/万人)',
        left:40,
        textStyle:{
            color:'#269ee4',
            fontSize:12
        }
    },
    grid:{
        y2:90,
    },
    tooltip: {
        trigger: 'item',
    },
    xAxis: {
        data: dataAxis,
        axisLabel:{
            interval : 0,
            formatter:function(hangyetype)  
            {  
                var hy='';
                if (hangyetype.length>3) {
                    hy= hangyetype.substring(0,3)+"…";
                }else{
                    hy=hangyetype;
                }
                return hy;
            }  
        },
        axisTick: {
            show: false
        },
    },
    yAxis: {
        show:false,
    },
    series: [
    {
        type: 'bar',
        barWidth: '15',
        itemStyle: {
            normal: {
                barBorderRadius:[15,15,0,0],
                color: function (params){
                    if (params.dataIndex%2==0){
                        return '#fff';
                    }else {
                        return '#6e52d4';
                    }
                }
            },
            emphasis:{
            }
        },
        data: data
    }
    ]
};
myChartPoptype.setOption(Poptype);

var myChartprofession = echarts.init(document.getElementById('audiprofession'));
var dataAxis = [],data = [];
for(var k in audiences.renkouzhiye){
    dataAxis.push(audiences.renkouzhiye[k].type);
    data.push(audiences.renkouzhiye[k].number);
}
var profession = {
    textStyle:{
        color:['#fff'],
    },
    title:{
        text:'TGA人口职业（单位/万人)',
        left:40,
        textStyle:{
            color:'#269ee4',
            fontSize:12
        }
    },
    grid:{

        y2:90,
    },
    tooltip: {
        trigger: 'item',
    },
    xAxis: {
        data: dataAxis,
        axisLabel:{
            interval : 0,
            formatter:function(hangyetype)  
            {  
                var hy='';
                if (hangyetype.length>3) {
                    hy= hangyetype.substring(0,3)+"…";
                }else{
                    hy=hangyetype;
                }
                return hy;
            }  
        },
        axisTick: {
            show: false
        },
    },
    yAxis: {
        show:false,
        name:'aaa',
        textStyle:{

        }
    },
    series: [
    {
        type: 'bar',
        barWidth: '15',
        itemStyle: {
            normal: {
                barBorderRadius:[15,15,0,0],
                color: function (params){
                    if (params.dataIndex%2==0){
                        return '#fff';
                    }else {
                        return '#8c8c8c';
                    }
                }
            },
            emphasis:{
            }
        },
        data: data
    }
    ]
};
myChartprofession.setOption(profession);
var myChartincome = echarts.init(document.getElementById('audiincome'));
var incomedata = [],incomeInf = [];
var incomecolorList=['#269ee4','#269ee4'];
var incomeopacity=[0.16,0.4,0.68,1]
var op=[68,40,15]
var incomenum = 0;
for(var k in audiences.jiatingshouru){
    incomenum+=20;
    incomedata.push({
        value: incomenum, name:audiences.jiatingshouru[k].type, 
        itemStyle: {
            normal: {
                color: '#269ee4',
                opacity:incomeopacity[k]
            }
        },

    });
    var incomeval=rounding(audiences.jiatingshouru[k].ratio,1,2) 
    incomeInf.push({value:incomeval,name:audiences.jiatingshouru[k].type})

}
optionincome = {
    textStyle:{
        color:['#fff'],
    },
    "tooltip": {
        "trigger": "axis",
    },
    series: [
    {
        top:0,
        name: '',
        type: 'funnel',
        left: '10%',
        width: '80%',
        gap: 10,
        minSize: 60,
        maxSize: 222,
        sort: 'ascending',
        label: {
            normal: {
                color: '#fff',
                position: 'left',
            },
        },
        labelLine: {
            normal: {
                length: 40,
                position: 'left',
                lineStyle: {
                    width: 0
                }
            }
        },
        data: incomedata,itemStyle: {
            normal: {
                borderWidth: 0,
            }
        }
    },
    {
        name: '',
        type: 'funnel',
        top:0,
        gap: 10,
        sort: 'ascending',
        label: {
            normal: {
                position: 'inside',
                formatter: '{c}%',
                textStyle: {
                    color: '#fff'
                }
            }
        },
        itemStyle: {
            normal: {
                borderWidth:0,
                opacity: 0
            }
        },
        data:incomeInf            
    }
    ]
};
myChartincome.setOption(optionincome);
var myChartBrand = echarts.init(document.getElementById('audiBrand'));
var Brandtype=[];
var Brandnumber=[];
var arrdata=[];
for(var k in audiences.Shoujipinpai){
    arrdata.push({value:audiences.Shoujipinpai[k].number,name:audiences.Shoujipinpai[k].type});
}
var optionBrand = {
    textStyle:{
        color:['#fff'],
    },
    tooltip : {
        trigger: 'item',
    },
    series : [
    {
        type: 'pie',
        radius : '65%',
        center: ['50%', '50%'],
        selectedMode: 'single',
        label: {
            normal: {
                formatter: '{b}',
            }
        },
        data:arrdata,
        itemStyle: {
            normal:{
                color: function (params){
                    var colorList = ['#ffffff','#abacb0','#4c4f57','#818388','#353841','#464a54','#797e89','#999fad'];
                    return colorList[params.dataIndex%8];
                }
            },
            emphasis: {
                shadowBlur: 10,
                shadowOffsetX: 0,
                shadowColor: 'rgba(0, 0, 0, 0.5)'
            }
        }

    }
    ]
};
myChartBrand.setOption(optionBrand);
var myCharInterest = echarts.init(document.getElementById('audiInterest'));
var interInf=[];
var Intertype=[],Internumber=[];
for(var k in audiences.XinquAihao){
    Internumber.push(rounding(audiences.XinquAihao[k].number,1,2));
}
var Infmax=Math.max.apply(null,Internumber);
for(var k in audiences.XinquAihao){
 interInf.push({text:audiences.XinquAihao[k].type,max:Infmax});
}
var Interest = {
    textStyle:{
        color:['#fff'],
    },
    tooltip: {
        trigger: 'axis'
    },
    legend: {
        orient:'vertical',
        top:'112',
        right:'5',
        textStyle:{
            color:'#fff'
        }
    },
    radar: [
    {
        indicator: interInf,
        center: ['50%', '50%'],
        radius: 90,
        splitNumber: 3,

        splitArea: {
            areaStyle: {
                color: [
                'rgba(255, 255, 255, 0)'
                ],
                shadowColor: 'rgba(0, 0, 0, 0.3)',
                shadowBlur: 10
            }
        },
        axisLine: {
            lineStyle: {
                color: 'rgba(60, 64, 76, 0.9)'
            }
        },
        splitLine: {
            lineStyle: {
                color: 'rgba(60, 64, 76, 0.9)'
            }
        }
    }
    ],
    series: [

    {
        color:['#91c7ae','#749f83'],
        name: '雷达图',
        type: 'radar',
        tooltip: {
            trigger: 'item'
        },
        itemStyle: {
            normal: {
                areaStyle: {
                    type: 'default',
                }
            }
        },
        data: [
        {
            value:Internumber,
            itemStyle:{
                normal:{color:'#e100ff'}
            },
            areaStyle:{
                normal:{opacity:0.5},
                emphasis: {opacity:0.7}
            },
            name: '参数一',
            symbol: 'rect',
            symbolSize: 1,
        },

        ]
    }
    ]
}
myCharInterest.setOption(Interest);

var myChartPlace = echarts.init(document.getElementById('audiPlace'));
var dataAxis = [],data = [];
for(var k in audiences.changfangdidian){
    dataAxis.push(audiences.changfangdidian[k].type);
    data.push(audiences.changfangdidian[k].number);
}
var optionPlace = {
    textStyle:{
        color:['#fff'],
    },
    grid:{

        y2:90,
    },
    tooltip: {

        trigger: 'item',
    },
    xAxis: {
        data: dataAxis,
        axisLabel:{
            interval : 0,
            formatter:function(hangyetype)  
            {  
                var hy='';
                if (hangyetype.length>3) {
                    hy= hangyetype.substring(0,3)+"…";
                }else{
                    hy=hangyetype;
                }
                return hy.split('').join('\n');
            }  
        },
        axisTick: {
            show: false
        },
    },
    yAxis: {
        show:false,
    },
    series: [
    {
        type: 'bar',
        barWidth: '15',
        itemStyle: {
            normal: {
                barBorderRadius:[15,15,0,0],
                color: function (params){
                    if (params.dataIndex%2==0){
                        return '#fff';
                    }else {
                        return '#8c8c8c';
                    }
                }
            },
            emphasis:{
            }
        },
        data: data
    }
    ]
};
myChartPlace.setOption(optionPlace);
var myChartedu = echarts.init(document.getElementById('audiEdu'));
var data=[],dataAxis=[];
for(var k in audiences.Xueli){
    dataAxis.push(audiences.Xueli[k].type);
    data.push(audiences.Xueli[k].number);
}
var max=Math.max.apply(null, data);
var yMax = max+100;
var dataShadow = [];
for (var i = 0; i < data.length; i++) {
 dataShadow.push(yMax);
}
var optionedu = {
    color:['#fff'],
    tooltip: {},
    textStyle:{
        color:['#fff'],
    },
    grid: {
        left: '5%',
        right: '4%',
        top:'4%',
        bottom: '0%',
        containLabel: true
    },

    xAxis: {
        show:false,
    },
    yAxis: {
        data:  dataAxis,
        axisTick: {
            show: false
        },
    },
    series: [
    { 
        type: 'bar',

        itemStyle: {
            normal: {color: 'rgba(57,61,73,0.4)',barBorderRadius:[0,15,15,0],},
            emphasis:{
                color: 'rgba(57,61,73,0)'
            }
        },
        barGap:'-100%',
        barWidth: '15',
        data: dataShadow,
        animation: false
    },
    {
        type: 'bar',
        data: data,
        itemStyle: {
            normal: {
                barBorderRadius:[0,15,15,0],
            },
        },
        barBorderRadius:[15,15,0,0],
        barWidth: '15',
    }]
};
myChartedu.setOption(optionedu);

$('.maskRight').outerHeight($('.maskLeft').outerHeight());
}
$('.mapbtn_blue').on('click',function () {
    [['北京', BJData],].forEach(function(item, i) {
        series.push({
            type: 'lines',
            coordinateSystem: 'bmap',
            zlevel: 2,
            effect: {
                show: true,
                period: 6,
                trailLength: 0,
            },
            lineStyle: {
                normal: {
                    color: color[i],
                    width: 1,
                    opacity: 0.4,
                    curveness: 0.2
                }
            },
            data: convertData(item[1])
        }
        );
    });
    myChart.setOption(option);
    series=[];
    $(this).toggleClass('cur').siblings().removeClass('cur');
    $(this).parents('.mapbtn_wrp').siblings('.mapbtn_wrp').find('.mapbtn').removeClass('cur')
    if ($(this).hasClass('cur')) {
        $('.BMapLabel').prev('div').css('display','block');
    }else {
        $('.BMapLabel').prev('div').css('display','none');
    }
    $('.axis').hide();
})
/**
 * 工作日周末地图按钮点击事件
 */
 $('.mapbtn_orange').on('click',function () {
    $('.BMapLabel').prev('div').css('display','none');
    $(this).addClass('cur').siblings().removeClass('cur');
    $(this).parents('.mapbtn_wrp').siblings('.mapbtn_wrp').find('.mapbtn').removeClass('cur');
    $('.axis').show();
    $('.axis').removeClass('weekend').addClass('workday');
})
 $('.mapbtn_purple').on('click',function () {
    $('.BMapLabel').prev('div').css('display','none');
    $(this).addClass('cur').siblings().removeClass('cur');
    $(this).parents('.mapbtn_wrp').siblings('.mapbtn_wrp').find('.mapbtn').removeClass('cur');
    $('.axis').show();
    $('.axis').removeClass('workday').addClass('weekend');
})
/**
 * 工作日周末地图按钮点击事件--end
 */

// var importInf = {
//     orderId:sessionStorage.getItem('orderId'),
//     cityCode:sessionStorage.getItem('cityCode')
// }

var SinglePARM={
    orderResultId:sessionStorage.getItem('orderResultId'),
    fnid:sessionStorage.getItem('fnid'),
    orderId:sessionStorage.getItem('orderId'),
    cityCode:sessionStorage.getItem('cityCode')   
}
$(function(){
    if (sessionStorage.getItem('fnid')) {
        getData('post',url,SingleCell,SinglePARM,detailsInf,$('body'));
    }else{
        getData('post',url,details,SinglePARM,detailsInf,$('body'));
    }
    $('.back').on('click','.planBack',function () {
        sessionStorage.removeItem('fnid');
        getData('post',url,details,SinglePARM,detailsInf,$('body'));
    })
    $('.mediatitle span').on('click',function () {
        $(this).parents('.mediatitle').siblings('.mediaechart').stop().slideToggle();
        $(this).parents('.media_wrp').siblings('.media_wrp').find('.mediaechart').stop().slideUp();
        $(this).parents('.wrpfr').siblings('.wrpfr').find('.mediaechart').stop().slideUp();
        $('.maskRight').outerHeight($('.maskLeft').outerHeight());
    })
})